import com.dtu.distributed.controller.TempController;
import com.dtu.distributed.filereader.ReadNodeList;

public class Main {

	public static void main(String[] args) {
		
		if (args.length<5) {
			System.out.println("Not enough arguments specified - admin, own_ip, my_admin_port, election_reply_port, rmi_port, nodelist file path");
			System.exit(0);
		}
		
		String myIpAddress = args[1];
		boolean isAdmin = Boolean.parseBoolean(args[0]);
		int myAdminTempPort = Integer.parseInt(args[2]);
		int electionPort = Integer.parseInt(args[3]);
				
		int rmiPort = Integer.parseInt(args[4]);
		String rmiRegistryName = myIpAddress + ":" + rmiPort;
		
		TempController.registryName = rmiRegistryName;
		TempController.myIpAddress = myIpAddress;
		TempController.myadminTemperaturePort = myAdminTempPort;
		TempController.electionPort = electionPort;
		TempController.rmiClientPort = rmiPort;
		
		if (isAdmin) {
			TempController.adminTemperatureIpAddress = myIpAddress;
			TempController.adminTemperaturePort = myAdminTempPort;
		}
		
		TempController.bindClientConnection();
		TempController.setNodelist(args[5]);
		TempController.startAdminElectionListenerThread();
		
		//Commented out while testing admin shifting
		TempController.startTemperatureThread();
		TempController.makeAdmin(isAdmin);
				
	}

}
